package com.manner.groupon.controller.store;

import com.manner.groupon.common.BaseResponse;
import com.manner.groupon.common.ResultUtils;
import com.manner.groupon.model.dto.grouponCoupons.StoreQueryGrouponCoupon;
import com.manner.groupon.service.groupon.GrouponCouponsService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: Manner
 * @Description: 处理商家的团购优惠券请求控制器
 * @DateTime: 2024/12/5 17:16
 */
@RestController("storeGrouponCouponController")
@RequestMapping("/store/groupon-coupon")
@RequiredArgsConstructor
public class GrouponCouponController {

    private final GrouponCouponsService grouponCouponsService;

    /**
     * @param phone 登录手机号账号
     * @return BaseResponse<StoreQueryGrouponCoupon>
     * @description: 商户门店联系人查询自己名下店铺的所有团购优惠券
     * @author Manner
     * @date 2024/12/5 17:26
     */
    @GetMapping("/all/{phone}")
    public BaseResponse<List<StoreQueryGrouponCoupon>> queryMyAll(@PathVariable String phone) {
        return ResultUtils.success(grouponCouponsService.queryMyAllGrouponCoupons(phone));
    }

    /**
     * @param grouponCouponId 团购优惠券编号
     * @description: 下架团购优惠券
     * @author Manner
     * @date 2024/12/5 19:04
     */
    @PostMapping("/remove/{grouponCouponId}/{status}")
    public BaseResponse<String> removeGrouponCoupon(@PathVariable Long grouponCouponId, @PathVariable int status) {
        grouponCouponsService.linkmanRemoveGrouponCoupon(grouponCouponId, status);
        return ResultUtils.success("编辑成功");
    }
}
